'''
from tkinter import *

master = Tk()

#theLB = Listbox(master,height=3)
#theLB = Listbox(master,selectmode=SINGLE)
theLB = Listbox(master,selectmode=EXTENDED)

theLB.pack()

theLB.insert(0,'欢迎光临')

for item in range(10):
    theLB.insert(END,item)

theLB.delete(1)
theLB.insert(END,'谢谢惠顾')

theButton = Button(master,text='删除它',\
                   command=lambda x=theLB:x.delete(ACTIVE))
theButton.pack()

mainloop()
'''

from tkinter import *

master = Tk()

theSB = Scrollbar(master)
theSB.pack(side=RIGHT,fill=Y)

#theLB = Listbox(master,height=3)
#theLB = Listbox(master,selectmode=SINGLE)
theLB = Listbox(master,selectmode=EXTENDED,yscrollcommand=theSB.set)

#theLB.pack(side=LEFT,fill=BOTH)
theLB.pack()

theLB.insert(0,'欢迎光临')

for item in range(100):
    theLB.insert(END,item)

theLB.delete(1)
theLB.insert(END,'谢谢惠顾')

theSB.config(command=theLB.yview)

theButton = Button(master,text='删除它',\
                   command=lambda x=theLB:x.delete(ACTIVE))
theButton.pack()

mainloop()
